#ifndef __INVADER_MENU_H__
#define __INVADER_MENU_H__

#include <list>

#include <QFrame>

class QGridLayout;
class QLabel;

class InvaderLabel;

/**
 * Implements a menu which is navigated with the arrow keys and entries are
 * selected with the Enter key.  It also uses the InvaderFont for text.
 */
class InvaderMenu : public QFrame
{
  Q_OBJECT

public:
  /**
   * @param items list of items of the menu
   * @param parent parent of the InvaderMenu
   */
  InvaderMenu (const QStringList &items, QWidget *parent = 0);

  /**
   * @returns the currently selected menu item
   */
  unsigned int getSelected () const { return _selected; }
  /**
   * Sets the currently selected menu item
   */
  void setSelected (unsigned int item);

signals:
  /**
   * Emitted when an item has been selected
   */
  void itemSelected (unsigned int item);
  /**
   * Emitted when keyboard activity is detected from the user
   */
  void activity ();

protected:
  void keyPressEvent (QKeyEvent *event);

private:
  QLabel *_cursor;
  unsigned int _numItems;
  unsigned int _selected;
  QGridLayout *_layout;

  void updateCursor ();
};

#endif
